import axios from "axios";

const axiosInstance = axios.create({
    timeout:6000
})

type Method='get'|'post';  // ts元组

export const request=(
    method:Method,
    url:string,
    // post {} ，get ？a=1
    data?:any  // 可有可无
    )=>{
        if(method==='post'){
            return axiosInstance.post(url,data);
        }
        else{
            return axiosInstance.get(url,{
                params:data
            })
        }
}